<%@ page import="model.subjects.Person, database.dao.PersonDAO, model.Attribute, java.util.LinkedList, model.Address, java.sql.Date" language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>
<jsp:useBean id="subject" scope="request" type="model.subjects.Person"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Isiku andmete muutmine</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="static/js/javascript.js"></script>

</head>
<a href='http://imbi.ld.ttu.ee/tomcat_webapp_logs/t103755_subjekt/log.txt'>loggid</a> ||<a href="LoginServlet?action=logout">Logi välja</a> 


<ul>
<a href='LoginServlet?action=login'>Otsing</a> || 
<a href='s?action=display_add_person'>Lisa Isikuid</a> || 
<a href='s?action=display_add_enterprise'>Lisa ettevõtteid</a> || 

</ul>



<body><h1>Isiku andmete muutmine</h1>

<a href="#" id="display_contacts" >Kontaktide</a>
<a href="#" id="display_addresses" >Aadressid</a>
<a href="#" id="display_modify_person" >Isiku Andmed</a>

<br>




<jsp:include page="Addresses.jsp"/>
<jsp:include page="Contacts.jsp"/><br/><br/>


<div id="show_modify_person">

<h1>Isiku andmed</h1>
<table>
<form action='s?action=modify_person' method='post' >

<!--  Üldised atribuudid -->

<input name="id" style="display:none" value="<%out.println(subject.getId());%>">
<tr><td>Eesnimi </td><td><input name="first_name" type="text" value="<%out.println(subject.getFirst_name());%>"><br/></td></tr>
<tr><td>Perenimi </td><td><input name="last_name" type="text" value="<%out.println(subject.getLast_name());%>"><br/></td></tr>
<tr><td>Isikukood </td><td><input name="identity_code" type="text" value="<%out.println(subject.getIdentity_code());%>"><br/></td></tr>
<tr><td>Sünnikuupäev </td><td><input name="birth_date" type="date" value="<%out.println(subject.getBirth_date());%>"><br/></td></tr>
<br/>
<%
//Isiku atribuudid

LinkedList<Attribute> attributes = subject.getAttributes();
for(Attribute a: attributes){
	int dataType = a.getDataType();
	out.println("<tr><td><label>"+a.getName()+ " </label></td><td><input name=\"" + a.getName() + "\" type=\"");
	if(dataType == 1){
		out.println("text\" value=\""+a.getValue()+"\" ");
	}else if(dataType == 2){
		out.println("number\" value=\""+a.getValue()+"\" ");
	}else{
		out.println("date\" value=\""+a.getValue()+"\" ");
	}
	//out.println("\" ");
	if(a.isRequired()){
		out.println("required");
	}
	out.println(" ><br/></td></tr>"); //inputi lõpp
	
}
%>
<br/>
<tr><td>Kliendiks </td><td><input name="make_customer" type="checkbox">
<br/></td></tr>


<tr><td> </td><td><input type="submit" value="Muuda"></tr></td></table>
</form>


</div>
</body>
</html>